package com.mao.lambda;

public class LambdaDemo1 {
    public static void main(String[] args) {
        Animal a = new Animal() {
            @Override
            public void eat() {
                System.out.println("猫吃鱼");
            }
        };
        a.eat();

        // lambda表达式只能简化函数式接口的匿名内部类

       Swim s = new Swim() {
           @Override
           public void swimming() {
               System.out.println("狗刨");
           }
       };
       s.swimming();

       Swim s1 = () -> {
           System.out.println("学生游泳飞快");
       };
       s1.swimming();
    }
}

abstract  class Animal{
    public abstract void eat();
}

// 函数式接口：只有一个抽象方法的接口。
@FunctionalInterface
interface Swim{
    public void swimming();
}
